export const ELEMENT_SETTER = Symbol("element-setter");

export type INode = HTMLElement | ShadowRoot;

export interface IElementSetter {
    [ELEMENT_SETTER](element: INode): void;
}

export function isElementSetter(value: unknown): value is IElementSetter {
    if (typeof value === "object" && value !== null) {
        return ELEMENT_SETTER in value;
    }
    return false;
}

export function setElement(element: INode, setter: unknown): boolean {
    if (isElementSetter(setter)) {
        setter[ELEMENT_SETTER](element);
        return true;
    }
    return false;
}
